home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QRZ! Ham Radio 8
/
QRZ Ham Radio Callsign Database - Volume 8.iso
/
pc
/
files
/
t_unix
/
bs941029.tgz
/
bbsx-941029.tar
/
bbsx
/
mkboxpwd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-29
|
1KB
|
49 lines
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#include <string.h>
main(int argc, char **argv)
{
FILE *fp;
char *filename;
unsigned int c;
time_t t;
int writetofile = 0;
int i;
while ((c = getopt(argc, argv, "o:")) != EOF) {
switch (c) {
case 'o':
writetofile = 1;
filename = strdup(optarg);
break;
default:
printf("usage: mkboxpwd [-o outputfile]\n");
exit (1);
}
}
srand((unsigned) time(&t));
if (writetofile) {
if ((fp = fopen(filename,"w")) == NULL) {
printf("can not open: %s\n", filename);
exit (1);
}
}
for (i=0; i < 1620; i++) {
do {
c = (char) random();
if (isalnum(c) && (c < 127)) {
fputc(c, writetofile ? fp : stdout);
/* if (!((i+1) % 27))
fputc('\n', writetofile ? fp : stdout); */
}
} while (!isalnum(c) || (c >= 127));
}
if (writetofile) {
fclose(fp);
chmod(filename,0600);
}
}